import tornado.ioloop
import tornado.web
from tornado.options import define,options,parse_command_line
# get  post
define('port',default=8080,type=int)

class MainHandler(tornado.web.RequestHandler):
    def get(self,*args,**kwargs):
        # name= self.get_argument('name',default='kangbazi',strip=True)
        # name= self.get_query_argument('name',default='kangbazi',strip=True)
        name= self.get_query_arguments('name',strip=True)
        #name= self.get('name',strip=True)
        self.write("hello %s" % name)
    def post(self):
        #name = self.get_body_argument('name',default='haha',strip=True)
        name = self.get_body_arguments('name',strip=True)
        self.write('Hello,%s' % name)
def make_app():
    return tornado.web.Application(handlers=[
        (r'/hello',MainHandler),
    ],autoreload=True,debug=True)

if __name__ == "__main__":
    #解析命令行
    parse_command_line()
    #调用make_app()
    app = make_app()
    #监听端口
    app.listen(options.port)
    tornado.ioloop.IOLoop.current().start()
